﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Lima.ResumeSys
{
    internal static class Program
    {
        private static Mutex mutex = new Mutex(true, "25B963A3-45C1-4A3A-9DA2-96BFB6D03354");
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            // 防止多开
            if (!mutex.WaitOne(TimeSpan.Zero, true))
            {
                MessageBox.Show("程序已经在运行中", "提示",
                              MessageBoxButtons.OK,
                              MessageBoxIcon.Information);
                return;
            }
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                // 显示登录窗体
                using (LoginForm loginForm = new LoginForm())
                {
                    if (loginForm.ShowDialog() != DialogResult.OK)
                    {
                        return; // 用户取消登录或登录失败，退出程序
                    }
                }
                Application.Run(new MainForm());
            }
            finally
            {
                mutex.ReleaseMutex();
            }
        }
    }
}
